package com.example.stringbufferlogger.dto;

import java.math.BigDecimal;
import java.util.Map;

public class LogEntryDTO {
    private String requestId;
    private String method;
    private String url;                // 完整URL（包含查询参数）
    private String path;               // 请求路径
    private String remoteIp;
    private String sessionId;          // 会话ID
    private long duration;
    private Map<String, String> headers;
    private Map<String, Object> requestParams;
    private String requestBody;
    private String responseBody;
    private boolean isUpload;
    private boolean isDownload;
    private String contentType;        // 请求内容类型
    private int status;                // 响应状态码
    private Map<String, String> sessionAttributes; // 会话属性

    private String replayStatus;          // 回放状态(0-待回放，1-回放完成)
    private String createTime;         // 记录创建时间

    private Map<String, Object> uploadFiles;  // 上传文件信息
    private Map<String, Object> downloadFile; // 下载文件信息
    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public String getMethod() {
        return method;
    }

    public void setMethod(String method) {
        this.method = method;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getSessionId() {
        return sessionId;
    }

    public void setSessionId(String sessionId) {
        this.sessionId = sessionId;
    }

    public String getContentType() {
        return contentType;
    }

    public void setContentType(String contentType) {
        this.contentType = contentType;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public Map<String, String> getSessionAttributes() {
//        if (this.sessionAttributes!=null){
//            return sessionAttributes.put("sessionAttributes", JSONObject.toJSONString(sessionAttributes));
//        }
        return sessionAttributes;
    }

    public void setSessionAttributes(Map<String, String> sessionAttributes) {
        this.sessionAttributes = sessionAttributes;
    }

    public String getPath() {
        return path;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getRemoteIp() {
        return remoteIp;
    }

    public void setRemoteIp(String remoteIp) {
        this.remoteIp = remoteIp;
    }

    public BigDecimal getDuration() {
        return BigDecimal.valueOf(duration);
    }

    public void setDuration(long duration) {
        this.duration = duration;
    }

    public Map<String, String> getHeaders() {
        return headers;
    }

    public void setHeaders(Map<String, String> headers) {
        this.headers = headers;
    }

    public Map<String, Object> getRequestParams() {
        return requestParams;
    }

    public void setRequestParams(Map<String, Object> requestParams) {
        this.requestParams = requestParams;
    }

    public String getRequestBody() {
        return requestBody;
    }

    public void setRequestBody(String requestBody) {
        this.requestBody = requestBody;
    }

    public String getResponseBody() {
        return responseBody;
    }

    public void setResponseBody(String responseBody) {
        this.responseBody = responseBody;
    }

    public boolean isUpload() {
        return isUpload;
    }

    public void setUpload(boolean upload) {
        isUpload = upload;
    }

    public boolean isDownload() {
        return isDownload;
    }

    public void setDownload(boolean download) {
        isDownload = download;
    }

    public String getCreateTime() {
        return createTime;
    }
    public String getReplayStatus() {
        return replayStatus;
    }
    public void setReplayStatus(String replayStatus) {
        this.replayStatus = replayStatus;
    }
    public Map<String, Object> getUploadFiles() {
        return uploadFiles;
    }
    public void setUploadFiles(Map<String, Object> uploadFiles) {
        this.uploadFiles = uploadFiles;
    }
    public Map<String, Object> getDownloadFile() {
        return downloadFile;
    }
    public void setDownloadFile(Map<String, Object> downloadFile) {
        this.downloadFile = downloadFile;
    }

    public LogEntryDTO() {
    }
    @Override
    public String toString() {
        return "LogEntryDTO{" +
                "requestId='" + requestId + '\'' +
                ", method='" + method + '\'' +
                ", url='" + url + '\'' +
                ", path='" + path + '\'' +
                ", remoteIp='" + remoteIp + '\'' +
                ", sessionId='" + sessionId + '\'' +
                ", duration=" + duration +
                ", headers=" + headers +
                ", requestParams=" + requestParams +
                ", requestBody='" + requestBody + '\'' +
                ", responseBody='" + responseBody + '\'' +
                ", isUpload=" + isUpload +
                ", isDownload=" + isDownload +
                ", contentType='" + contentType + '\'' +
                ", status=" + status +
                ", sessionAttributes=" + sessionAttributes +
                ", replayStatus='" + replayStatus + '\'' +
                ", createTime='" + createTime + '\'' +
                ", uploadFiles=" + uploadFiles +
                ", downloadFile=" + downloadFile +
                '}';
    }



}